home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / comm / mebbs / mnl010.lha / MN.L010 < prev    next >
Text File  |  1994-11-24  |  17KB  |  548 lines

  1. /*
  2.   Name:          MN.L010
  3.   Purpose:       Create MEBBSNet Call Log
  4.   Author:        R Pope
  5.   Date Written:  02-Aug-90 v1.00
  6.        Revised:  05-Aug-90 v1.01  Calculation Error on Time Used
  7.                  08-Aug-90 v1.02  Error when Limit Exceeded
  8.                  11-Aug-90 v1.03  Run from Ram Copy of Log
  9.                  13-Aug-90 v1.10  Add Daily Totals
  10.                  15-Aug-90 v1.20  Added ParagonX.Log file trimming
  11.                  17-Aug-90 v1.21  Page Break on Date Break
  12.                  19-Aug-90 v1.22  More Error Information
  13.                  19-Aug-90 v1.23  Correct Post-Download Disconnect being
  14.                                   treated as having left a message
  15.                  01-Sep-90 v1.24  Description of uploaded file treated as
  16.                                   a download.  Corrected.
  17.                  18-Nov-90 v1.30  Added FidoNet sessions
  18.                  03-Dec-90 v1.31  Added ~vp to correct for v2.08r change
  19.                  27-Dec-90 v1.32  1. LoTek transfers added to Fido
  20.                                   2. Fido transfers included in stats
  21.                  18-Sep-91 v1.33  Conversion for HiSoft compiler
  22.                  07-Oct-91 v2.00  Converted to ARexx
  23.                  20-Oct-91 v2.01  Line noise entries handled
  24.                  13-Nov-91 v2.02  Fidonet entries lost during ARexx conv
  25.                  21-Nov-91 v2.10  Line # added
  26.                  17-Dec-91 v3.00  Converted to StarNet; ANSI added
  27.                  04-Jan-92 v3.01  "/" in name converted to "-"
  28.                                   Changed to one trimfile per node
  29.                  21-Nov-92 v3.02  Modified to handle 5-character baud rates
  30.                  12-Dec-93 v4.00  Converted to MEBBSNet
  31.                  23-Nov-94 v4.10  Converted for MEBBSNet v0.160
  32.   FILES:         MEBBSNet Log File(s)
  33.                  Ram Copy of MEBBSNet Log File(s)
  34.                  MEBBSNet configuration file
  35.                  Caller Log File
  36.                  Config File
  37. */
  38.   pgmver = 'MN.L010 v4.10 23-Nov-94'
  39.   say pgmver||' by Dick Pope'
  40.   conpath = 'MEBBSNet:MEBBSNet.con'
  41.   call readcon
  42.   trimpath = mainpath||'s/TrimFl'
  43.   cfgpath = mainpath||'ConfigFiles/mn.l010.cfg'
  44.   parse arg altcfg
  45.   if altcfg ~= '' then cfgpath = altcfg
  46.   call config
  47.   mainpath = 'dwn:rexx/'
  48.   months = ':Jan:Feb:Mar:Apr:May:Jun:Jul:Aug:Sep:Oct:Nov:Dec:'
  49.   hdr = '  Date     On    Off  Name              Ln  Baud  Used  U/L D/L Msg'
  50.   red = ''
  51.   green = ''
  52.   yellow = ''
  53.   pink = ''
  54.   ltblue = ''
  55.   white = ''
  56.   hapos = d2c(39)
  57.   bl = '                                                  '
  58.   call clrcall
  59.   call clrtot
  60.   open('clg','ram:calllog.txt','w')
  61.   do nn = 1 to numnodes
  62.      linenum = nn
  63.      limit.nn = 0
  64.      hi.nn = 0
  65.      curnode = substr(nodes,nn,1)
  66.      address command 'copy ' mainpath||'MEBBSNet'||curnode||'.log ram:logfile'
  67.      open('stl','ram:logfile','r')
  68.      stldata = readln('stl')
  69.      do while eof('stl') = 0
  70.         hi.nn = hi.nn + 1
  71.         if left(stldata,1) = '|' then do
  72.            parse var stldata intype indate intime indata
  73.            intype = strip(intype,'b')
  74.            indate = strip(indate,'b')
  75.            intime = strip(intime,'b')
  76.            indata = strip(indata,'b')
  77.            if length(indate) ~= 9 then do
  78.               indate = left(indate,4)||'0'||substr(indate,5)
  79.            end
  80.            tmp = (pos(left(indate,3),months) + 2) / 4
  81.            if length(tmp) = 1 then tmp = '0'||tmp
  82.            compdate = '19'||substr(indate,8,2)||tmp||substr(indate,5,2)
  83.            dayoff = date('b',compdate,'s')
  84.            z = upper(indata)
  85.            intype = 'detail'
  86.            if pos('OPERATIONAL',z) > 0 then intype = 'header'
  87.            if pos('STARTING MAIL-ONLY EVENT',z) > 0 then intype = 'header'
  88.            if pos('EVENT CHANGE',z) > 0 then intype = 'header'
  89.  
  90.            if pos('WAZOO:',z) > 0 then do
  91.               intype = 'connect'
  92.               incall = 'wazoo'
  93.            end
  94.            if pos('EMSI CONNECT',z) > 0 then do
  95.               intype = 'connect'
  96.               incall = 'emsi'
  97.            end
  98.            if pos('NORM. LOGON: USER',z) > 0 then do
  99.               intype = 'connect'
  100.               incall = 'normal'
  101.            end
  102.            if pos('NEW USER: USER',z) > 0 then do
  103.               intype = 'connect'
  104.               incall = 'normal'
  105.            end
  106.            if pos('ENTERED BBS LOCALLY',z) > 0 then do
  107.               intype = 'connect'
  108.               incall = 'normal'
  109.            end
  110.            if pos('BAUD CONNECTION',z) > 0 then do
  111.               intype = 'connect'
  112.               incall = 'normal'
  113.            end
  114.  
  115.            if upper(indata) = 'LOGOFF' then intype = 'off'
  116.  
  117.            if dayoff >= dateset.nn then do
  118.               if limit.nn = 0 then limit.nn = hi.nn
  119.               if incall = 'wazoo' then call wazoo
  120.               if incall = 'emsi' then call emsi
  121.               if intype = 'header' then call header
  122.               if intype = 'detail' then call detail
  123.               if intype = 'off' then call endcall
  124.               if intype = 'connect' then call connect
  125.            end
  126.         end
  127.         stldata = readln('stl')
  128.      end
  129.      close('stl')
  130.   end
  131.   address command 'delete ram:logfile quiet'
  132.   endfl = 'Y'
  133.   call newcall
  134.   close('clg')
  135.   address command 'sort ram:calllog.txt ram:calllog.srt'
  136.   address command 'delete ram:calllog.txt quiet'
  137.   call logprt
  138.   address command 'delete ram:calllog.srt quiet'
  139.   if trim = 'Y' then call trimfile
  140.   exit 0
  141. /*
  142. ***********************************************************************
  143. *** Connect
  144. ***********************************************************************
  145. */
  146. connect:
  147.   if pos('BAUD CONNECTION',upper(indata)) > 0 then do
  148.      call newcall
  149.   end
  150.   psn = pos('line ',indata)
  151.   if psn > 0 then do
  152.      hln = '1'
  153.      if psn > 0 then do
  154.         hln = substr(indata,psn+5)
  155.         psn = pos('.',hln)
  156.         if psn > 0 then hln = left(hln,psn-1)
  157.      end
  158.   end
  159.   if pos('baud',indata) > 0 then do
  160.      psn = pos('/',indata)
  161.      if psn = 0 then do
  162.        psn = pos(' ',indata)
  163.         hbaud = left(indata,psn-1)
  164.      end
  165.      if psn ~= 0 then hbaud = left(indata,psn-1)
  166.   end
  167.   hon = intime
  168.   hdate = indate
  169.   if incall = 'normal' then do
  170.     psn = pos(' USER ',upper(indata))
  171.     if psn > 0 then do
  172.        psn = pos(hapos,indata)
  173.        if psn > 0 then hname = substr(indata,psn+1)
  174.        psn = pos(hapos,hname)
  175.        if psn > 0 then hname = left(hname,psn-1)
  176.     end
  177.   end
  178.   return
  179. /*
  180. ***********************************************************************
  181. *** Scan Header
  182. ***********************************************************************
  183. */
  184. header:
  185.   call endcall
  186.   return
  187. /*
  188. ***********************************************************************
  189. *** Scan detail
  190. ***********************************************************************
  191. */
  192. detail:
  193.   if pos('LEFT FEEDBACK',z) > 0 then hmsg = hmsg + 1
  194.   if pos('LEFT E-MAIL',z) > 0 then hmsg = hmsg + 1
  195.   if pos('POSTED ',z) > 0 then hmsg = hmsg + 1
  196.   if pos('MATRIX MAIL',z) > 0 then hmsg = hmsg + 1
  197.   if pos(' DL ',z) > 0 then hdl = hdl + 1
  198.   if pos(' DOWNLOAD ',z) > 0 then hdl = hdl + 1
  199.   if pos(' DOWNLOADED ',z) > 0 then hdl = hdl + 1
  200.   if pos('X-SEND ',z) > 0 then hdl = hdl + 1
  201.   if pos('Z-SEND ',z) > 0 then hdl = hdl + 1
  202.   if pos('SENDING MAIL TO ',z) > 0 then hdl = hdl + 1
  203.   if pos('UPLOAD',z) > 0 then hul = hul + 1
  204.   if pos('X-REC ',z) > 0 then hul = hul + 1
  205.   if pos('Z-REC ',z) > 0 then hul = hul + 1
  206.   if pos('LOGGED OUT',z) > 0 then hnote = 'Normal'
  207.   if pos('POST-DOWNLOAD',z) > 0 then hnote = 'Normal'
  208.   if pos('TIME LIMIT',z) > 0 then hnote = 'Time'
  209.   if pos('IDLED',z) > 0 then hnote = 'Sleep'
  210.   if pos('LOST CARRIER',z) > 0 then hnote = 'Carrier'
  211.  
  212.   if pos('ZEDZAP',z) > 0 then hnote = 'Normal'
  213.   hoff = intime
  214.   return
  215. /*
  216. ***********************************************************************
  217. *** Logoff Routine
  218. ***********************************************************************
  219. */
  220. endcall:
  221. /*
  222.   call newcall
  223. */
  224.   return
  225. /*
  226. ***********************************************************************
  227. *** Wazoo Routine
  228. ***********************************************************************
  229. */
  230. wazoo:
  231.   intype = ''
  232.   if hon = '' then do
  233.      hon = intime
  234.      hdate = indate
  235.   end
  236.   if pos('WaZoo:',indata) > 0 then do
  237.      parse var indata ind01 ind02
  238.      hname = strip(ind02,'b')
  239.   end
  240.   if pos('Z-Send',indata) > 0 then hdl = hdl + 1
  241.   if pos('received',indata) > 0 then hul = hul + 1
  242.   hoff = intime
  243.   return
  244. /*
  245. ***********************************************************************
  246. *** EMSI Routine
  247. ***********************************************************************
  248. */
  249. emsi:
  250.   intype = ''
  251.   if hon = '' then do
  252.      hon = intime
  253.      hdate = indate
  254.   end
  255.   if pos('System:',indata) > 0 then do
  256.      parse var indata ind01 ind02
  257.      hname = strip(ind02,'b')
  258.   end
  259.   if pos('Z-Send',indata) > 0 then hdl = hdl + 1
  260.   if pos('received',indata) > 0 then hul = hul + 1
  261.   hoff = intime
  262.   return
  263. /*
  264. ***********************************************************************
  265. *** New Call
  266. ***********************************************************************
  267. */
  268. newcall:
  269.   hname = strip(hname,'b')
  270.   if hname ~= '' then do
  271.      if upper(strip(hnote,'b')) = 'NORMAL' then hnote = ''
  272.      a1 = left(hname||'                 ',18)
  273.      a2 = left(hdate||'         ',9)
  274.      a3 = left(hon||'     ',5)
  275.      a4 = left(hoff||'     ',5)
  276.      a5 = right('   '||hdl,3)
  277.      a6 = right('   '||hul,3)
  278.      a7 = right('   '||hmsg,3)
  279.      a8 = right('     '||hbaud,5)
  280.      a9 = right(' '||hln,1)
  281.      a10 = left(hnote||'       ',7)
  282.      call timecalc
  283.      tmp = a2||'~'||a3||'~'||a4||'~'||a1||'~'||a9||'~'||a8||'~'||a11||'~'
  284.      tmp = tmp||a6||'~'||a5||'~'||a7||'~'||a10||'~'
  285.      tmp1 = (pos(left(hdate,3),months) + 2) / 4
  286.      if length(tmp1) = 1 then tmp1 = '0'||tmp1
  287.      tmp1 = 99 - tmp1
  288.      tmp2 = 99 - substr(hdate,5,2)
  289.      tmp3 = 99 - substr(hdate,8,2)
  290.      compdate = tmp3||tmp1||tmp2
  291.      tmp1 = 99 - left(hon,2)
  292.      tmp2 = 99 - substr(hon,4,2)
  293.      comptime = tmp1||tmp2
  294.      tmp = compdate||comptime||'~'||tmp
  295.      writeln('clg',tmp)
  296.   end
  297.   call clrcall
  298.   return
  299. /*
  300. ***********************************************************************
  301. *** Time Calculation Routine
  302. ***********************************************************************
  303. */
  304. timecalc:
  305.   hon = strip(hon,'b')
  306.   hoff = strip(hoff,'b')
  307.   if hon = '' then hon = '00:00'
  308.   if hoff = '' then hoff = '00:00'
  309.   parse var hon hon1 ':' hon2
  310.   parse var hoff hoff1 ':' hoff2
  311.   hon0 = 60 * hon1 + hon2
  312.   hoff0 = 60 * hoff1 + hoff2
  313.   if hoff0 < hon0 then hoff0 = hoff0 + 1440
  314.   hdiff0 = hoff0 - hon0
  315.   hdiff1 = hdiff0 / 60
  316.   if pos('.',hdiff1) = 0 then hdiff1 = hdiff1||'.00'
  317.   hdiff1 = trunc(hdiff1)
  318.   hdiff2 = hdiff0 - 60 * hdiff1
  319.   hdiff1 = right('00'||hdiff1,2)
  320.   hdiff2 = right('00'||hdiff2,2)
  321.   a11 = hdiff1||':'||hdiff2
  322.   return
  323. /*
  324. ***********************************************************************
  325. *** Clear Caller Values
  326. ***********************************************************************
  327. */
  328. clrcall:
  329.   hdate = ''
  330.   hon = ''
  331.   hoff = ''
  332.   hname = ''
  333.   hln = ''
  334.   hbaud = ''
  335.   hul = 0
  336.   hdl = 0
  337.   hmsg = 0
  338.   hnote = ''
  339.   incall = 'normal'
  340.   return
  341. /*
  342. ***********************************************************************
  343. *** Clear Totals
  344. ***********************************************************************
  345. */
  346. clrtot:
  347.   htotcalls = 0
  348.   htotul = 0
  349.   htotdl = 0
  350.   htotmsg = 0
  351.   htottime = 0
  352.   return
  353. /*
  354. ***********************************************************************
  355. *** Write Log
  356. ***********************************************************************
  357. */
  358. logprt:
  359.   ln = 0
  360.   prvdt = ''
  361.   open('cls','ram:calllog.srt','r')
  362.   open('clr',calllog,'w')
  363.   if gfx = 'Y' then do
  364.      open('clrA',calllogA,'w')
  365.      writeln('clrA','')
  366.   end
  367.   clrdata = readln('cls')
  368.   do while eof('cls') = 0
  369.      parse var clrdata  tmp '~' a2 '~' a3 '~' a4 '~' a1 '~' a11 '~' a9 '~' a5 '~' a7 '~' a6 '~' a8 '~' a10 '~'
  370.      clrdata1 = green||a2||' '||ltblue||a3||' '||red||a4||' '||green||a1
  371.      clrdata1 = clrdata1||' '||ltblue||a11||' '||red||a9||' '||white||a5
  372.      clrdata1 = clrdata1||' 'pink||a7||' '||a6||' '||a8||' '||white||a10
  373.      if a1 ~= '' then do
  374.         if ln / 20 = trunc(ln / 20) then do
  375.            if ln ~= 0 then writeln('clr','~vc')
  376.            writeln('clr',hdr)
  377.            if gfx = 'Y' then do
  378.               if ln ~= 0 then writeln('clrA','~vc')
  379.               writeln('clrA',white||hdr)
  380.            end
  381.         end
  382.         if prvdt ~= a2 then call datebrk
  383.         do while pos('~',clrdata) > 0
  384.            psn = pos('~',clrdata)
  385.            clrdata = left(clrdata,psn-1)||' '||substr(clrdata,psn+1)
  386.         end
  387.         clrdata = substr(clrdata,11)
  388.         writeln('clr',clrdata)
  389.         if gfx = 'Y' then do
  390.            writeln('clrA',clrdata1)
  391.         end
  392.         t1 = left(a5,2)
  393.         t2= substr(a5,4)
  394.         ln = ln + 1
  395.         totc = totc + 1
  396.         totd = totd + a6
  397.         totm = totm + a8
  398.         tott = tott + 60 * t1 + t2
  399.         totu = totu + a7
  400.         prvdt = a2
  401.      end
  402.      clrdata = readln('cls')
  403.   end
  404.   prvdt = 'xxxxxxxxx'
  405.   call datebrk
  406.   close('cls')
  407.   close('clr')
  408.   if gfx = 'Y' then do
  409.      close ('clrA')
  410.   end
  411.   return
  412. /*
  413. ***********************************************************************
  414. *** Daily Totals
  415. ***********************************************************************
  416. */
  417. datebrk:
  418.   if prvdt ~= '' then do
  419.      t1 = trunc(tott / 60)
  420.      t2 = tott - 60 * t1
  421.      tmp1 = right('00'||strip(t1),2)
  422.      tmp2 = right('00'||strip(t2),2)
  423.      tmp = tmp1||':'||tmp2
  424.      totc = right(bl||totc,3)
  425.      work = 'Calls: '||totc
  426.      totu = right(bl||totu,3)
  427.      totd = right(bl||totd,3)
  428.      totm = right(bl||totm,3)
  429.      work = left(bl,22)||work||left(bl,17)
  430.      work = work||tmp||' '||totu||' '||totd||' '||totm
  431.      work1 = left(bl,22)||white||'Calls: '||green||totc||left(bl,17)
  432.      work1 = work1||white||tmp||' '||pink||totu||' '||totd||' '||totm
  433.      writeln('clr',work)
  434.      if prvdt = 'xxxxxxxxx' then do
  435.         writeln('clr','')
  436.         writeln('clr',pgmver)
  437.      end
  438.      writeln('clr','~vc')
  439.      if prvdt ~= 'xxxxxxxxx' then writeln('clr',hdr)
  440.      if gfx = 'Y' then do
  441.         writeln('clrA',work1)
  442.         if prvdt = 'xxxxxxxxx' then do
  443.            writeln('clrA','')
  444.            writeln('clrA',ltblue||pgmver)
  445.         end
  446.         writeln('clrA','~vc')
  447.         if prvdt ~= 'xxxxxxxxx' then writeln('clrA',white||hdr)
  448.      end
  449.      ln = 0
  450.   end
  451.   totc = 0
  452.   totd = 0
  453.   totm = 0
  454.   tott = 0
  455.   totu = 0
  456.   return
  457. /*
  458. **********************************************************************
  459. *****  Read MEBBSNet Configuration File
  460. **********************************************************************
  461. */
  462. readcon:
  463.   open('con',conpath,'r')
  464.   condata = readch('con',60000)
  465.   close('con')
  466.   tmp = left(condata,64)
  467.   psn = pos('00'x,tmp)
  468.   mainpath = left(tmp,psn-1)
  469.   tmp = substr(condata,50881,64)
  470.   psn = pos('00'x,tmp)
  471.   txtpath = left(tmp,psn-1)
  472.   condata = ''
  473.   return
  474. /*
  475. **********************************************************************
  476. *** Create Script to Trim Log File
  477. **********************************************************************
  478. */
  479. trimfile:
  480.   do i=1 to numnodes
  481.      curnode = substr(nodes,i,1)
  482.      open('trm',trimpath||curnode||'.scr','w')
  483.      writeln('trm','.key noname')
  484.      writeln('trm','.bra {')
  485.      writeln('trm','.ket }')
  486.      if limit.i > 1 then do
  487.         diff = hi.i - limit.i + 1
  488.         work = 'trimfile '||mainpath||'MEBBSNet'||curnode||'.log -'||diff
  489.         writeln('trm',work)
  490.      end
  491.      close('trm')
  492.   end
  493.   return
  494. /*
  495. ***********************************************************************
  496. *** Read Config File
  497. ***********************************************************************
  498. */
  499. config:
  500.   nodes = '1'
  501.   do i = 1 to 10
  502.      limit.i = 10
  503.   end
  504.   calllog = txtpath||'Caller.txt'
  505.   calllogA = txtpath||'Caller.gr1'
  506.   trim = 'NO'
  507.   gfx = 'N'
  508.   open('cfg',cfgpath,'r')
  509.   cfgdata = readln('cfg')
  510.   do while eof('cfg') = 0
  511.      psn = pos('=',cfgdata)
  512.      cf1 = left(cfgdata,psn-1)
  513.      cf2 = substr(cfgdata,psn+1)
  514.      if upper(cf1) = 'NODES' then nodes = cf2
  515.      if upper(cf1) = 'FILE' then do
  516.         clog = cf2
  517.         psn = pos('.',clog)
  518.         if psn ~= 0 then clog = left(clog,psn-1)
  519.         calllog = clog||'.txt'
  520.         calllogA = clog||'.gr1'
  521.      end
  522.      if upper(cf1) = 'LIMIT' then limit = cf2
  523.      if upper(cf1) = 'TRIM' then trim = upper(cf2)||'N'
  524.      if upper(cf1) = 'GRAPHICS' then gfx = upper(cf2)||'N'
  525.      if upper(cf1) = 'NODES' then do
  526.         nodes = cf2
  527.         nodes = strip(nodes,'b')
  528.         if nodes = '' then nodes = '1'
  529.      end
  530.      cfgdata = readln('cfg')
  531.   end
  532.   close ('cfg')
  533.   numnodes = length(nodes)
  534.   trim = left(trim,1)
  535.   gfx = left(gfx,1)
  536.   if right(limit,1) ~= '/' then limit = limit||'/'
  537.   limit = limit||' '
  538.   datetot = date('basedate')
  539.   n = 0
  540.   do while pos('/',limit) > 0
  541.      n = n + 1
  542.      psn = pos('/',limit)
  543.      limit.n = left(limit,psn-1)
  544.      limit = substr(limit,psn+1)
  545.      dateset.n = datetot - limit.n
  546.   end
  547.   return
  548.